﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MCDirectBroadcast.Entity;

namespace MCDirectBroadcast.Controls {
    /// <summary>
    /// Interaction logic for UctStoryViewer.xaml
    /// </summary>
	public partial class UctStoryViewer : UserControl
	{
		public Story Stry { get; set; }

		public UctStoryViewer()
		{
			InitializeComponent();
			InitEvents();
		}

		void InitEvents()
		{
			this.Loaded += new RoutedEventHandler(UctStoryViewer_Loaded);
		}

		void UctStoryViewer_Loaded(object sender, RoutedEventArgs e)
		{
			if (this.Stry != null)
			{
				Fill(this.Stry);
			}
		}

		public void Fill(Story s)
		{
			if (s.ID > 0)
			{
				tbTitle.Text = s.Title;
				tbTimeCteate.Text = s.CreateDate.ToString();
				tbEvLoc.Text = s.Location;
				tbSchedul.Text = s.TimeToGo;

				string utfforce = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />";
				htmlContent.NavigateToString(utfforce + s.Content);
			}
		}
	}
}
